package com.example.pro01;

import androidx.appcompat.app.AppCompatActivity;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ProgressBar;

public class MainActivity extends AppCompatActivity {

    @SuppressLint("ClickableViewAccessibility")
    public void btnEvent() {
        Button btn1 = null;
        // 点击事件
        btn1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                System.out.println("点击事件...");
            }
        });
        // 长按事件
        btn1.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View view) {
                System.out.println("长按事件...");
                return false;
            }
        });
        // 触摸事件
        btn1.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View view, MotionEvent motionEvent) {
                System.out.println("触摸事件...");
                return false;
            }
        });
    }

//    public void Edit() {
//        EditText username = findViewById(R.id.edit_username);
//        EditText password = findViewById(R.id.edit_password);
//        Button login = findViewById(R.id.btn_login);
//
//        login.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//                String strUsername = username.getText().toString();
//                String strPassword = password.getText().toString();
//
//                Log.i("login", "用户名: " + strUsername);
//                Log.i("login", "密码: " + strPassword);
//                if (strUsername.equals("admin") && strPassword.equals("123456")) {
//                    Log.i("success", "登陆成功!");
//                } else {
//                    Log.e("failure", "登陆失败!");
//                }
//            }
//        });
//    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        ProgressBar progressBar = findViewById(R.id.pro1);
        Button button = findViewById(R.id.btn1);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                int progress = progressBar.getProgress();
                progress += 10;
                progressBar.setProgress(progress);
            }
        });
    }
}